package lumis.portal.audit;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NamedQuery;

/**
 * Represents the Audit category.
 *
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
@Entity
@GenericGenerator(name="portal-guid", strategy="lumis.portal.dao.hibernate.GuidGenerator")
@Table(name="lum_AuditCategory")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@NamedQuery(name = AuditCategory.NAMED_QUERY_FIND_BY_KEY, query = "select a from AuditCategory a where a.key = :key", cacheable=true, cacheRegion=IAuditManager.QUERY_CACHE_REGION)
public class AuditCategory
{
	/**
	 * Name of named query that returns {@link AuditCategory} 
	 * filtering by parameter <code>key</code>.
	 * @since 6.0.0
	 */
	static final String NAMED_QUERY_FIND_BY_KEY = "findAuditCategoryByKey";

	
	@Id	@GeneratedValue(generator="portal-guid")
	@Column(name="categoryId", nullable=false)
	private String id;

	@Column(name="auditCategoryKey")
	private String key;

	@Column(name="name")
	private String name;
	
	@Column(name="description")
	private String description;
	
	@Column(name="enabled")
	private boolean enabled;
	
	/**
	 * Returns the category id.
	 * @return	category id.
	 * @since 6.0.0
	 */
	public String getId()
	{
		return id;
	}

	/**
	 * Sets the category id.
	 * @param id	the category id.
	 * @since 6.0.0
	 */
	void setId(String id)
	{
		this.id = id;
	}

	/**
	 * Returns the category key.
	 * @return	the category key.
	 * @since 6.0.0
	 */
	public String getKey()
	{
		return key;
	}

	/**
	 * Sets the category key.
	 * @param key	the category key.
	 * @since 6.0.0
	 */
	public void setKey(String key)
	{
		this.key = key;
	}

	/**
	 * Returns the category name.
	 * @return	the category name.
	 * @since 6.0.0
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * Sets the category name.
	 * @param name	the category name.
	 * @since 6.0.0
	 */
	public void setName(String name)
	{
		this.name = name;
	}

	/**
	 * Returns the category description.
	 * @return	the category description.
	 * @since 6.0.0
	 */
	public String getDescription()
	{
		return description;
	}

	/**
	 * Sets the category description.
	 * @param description	the category description.
	 * @since 6.0.0
	 */
	public void setDescription(String description)
	{
		this.description = description;
	}
	
	/**
	 * Returns true if the category is enabled, false otherwise.
	 * @return true if the category is enabled, false otherwise.
	 * @since 6.0.0
	 */
	public boolean isEnabled()
	{
		return enabled;
	}

	/**
	 * Changes the enabled category flag.
	 * @param enabled	true for enabling category, false for disabling.
	 * @since 6.0.0
	 */
	public void setEnabled(boolean enabled)
	{
		this.enabled = enabled;
	}	
}